package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "护理等级")
@RequestMapping("/nursingLevel")
public class NursingLevelController {

    @Autowired
    private NursingLevelService nursingLevelService;

    @GetMapping("/listAll")
    @ApiOperation("查询所有的护理等级")
    public ResponseResult<List<NursingLevelVo>> getAllNursingLevel() {
        List<NursingLevelVo> nursingLevelVoList =  nursingLevelService.getAllNursingLevel();
        return ResponseResult.success(nursingLevelVoList);
    }

    @GetMapping("/listByPage")
    @ApiOperation("护理等级分页查询")
    public ResponseResult<NursingLevelVo> getNursingLevelList(NursingLevelDto nursingLevelDto) {
        PageResponse<NursingLevelVo> nursingLevelVoList =  nursingLevelService.getNursingLevelList(nursingLevelDto);
        return ResponseResult.success(nursingLevelVoList);
    }

    @GetMapping("{id}")
    @ApiOperation("回显")
    public ResponseResult<NursingLevelVo> getNursingLevelById(@PathVariable Long id) {
        NursingLevelVo nursingLevelVo = nursingLevelService.getNursingLevelById(id);
        return ResponseResult.success(nursingLevelVo);
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除护理计划")
    public ResponseResult deleteNursingLevelById(@PathVariable Long id) {
        nursingLevelService.deleteNursingLevelById(id);
        return ResponseResult.success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult updateNursingLevelStatus(@PathVariable Long id, @PathVariable Integer status) {
        nursingLevelService.updateNursingLevelStatus(id,status);
        return ResponseResult.success();
    }

    @PostMapping("/insert")
    @ApiOperation("新增护理等级")
    public ResponseResult addNursingLevel(@RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.addNursingLevel(nursingLevelDto);
        return ResponseResult.success();
    }

    @PutMapping("/update")
    @ApiOperation("修改护理等级")
    public ResponseResult updateNursingLevel(@RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.updateNursingLevel(nursingLevelDto);
        return ResponseResult.success();
    }

}
